#include <fstream>
#include <iostream>
#include <memory>
#include <unordered_map>
#include <utility>

#include "src/astar.h"
#include "src/point.h"

using namespace pathfind;

int main(int argc, char **argv) {
  if (argc < 1)
    return -1;

  std::string path("../../test/dhjw2");

  std::unordered_map<IntPoint, int> _map;

  std::ifstream file(path.c_str(), std::ios::binary | std::ios::in);

  int32_t val;
  for (int i = 0; i < 128 && !file.eof(); i++) {
    for (int j = 0; j < 128 && !file.eof(); j++) {
      file.read(reinterpret_cast<char *>(&val), sizeof(val));
      if (val != 0) {
        // std::cout << i << "," << j << " - " << val << " | ";
        _map.insert(std::make_pair(IntPoint(i, j), val));
      }
    }
    // std::cout << std::endl;
  }

  Astar _astar(_map, 128, 128);

  IntPoint _start(100, 26);
  IntPoint _end(106, 68);

  std::cout << _start.x << ", " << _start.y << std::endl;
  std::cout << _end.x << ", " << _end.y << std::endl;

  auto _result = _astar.finding(_start, _end);

  for (int i = 0; i < _result.size(); i++) {
    std::cout << _result[i] << std::endl;
  }

  return 0;
}
